clear all; close all; clc;

R = 220;
C =33e-12;
RC=R*C;
Tmod = 10*RC;
T = RC / 1000;
t = 0:T:3*Tmod;

f = 20000000; 
A = [0; 1; 2; 3];
U = nan(length(A), length(t));
for n = 1:length(A)
 E = A(n)*cos(2*pi*f*t);
 Uc(1) = E(1); dU(1) = 0;

 for k = 2:length(t)
 Uc(k) = (RC*Uc(k-1) + E(k)*T) / (RC + T);
 end
U(n, :) = Uc ;
end
figure(1);
plot(t*1e9, [E; U]);
xlabel('t, ns') 
ylabel('E, U, Volt')
legend('E(t|A=3)', 'U(t|A=0)', 'U(t|A=1)', 'U(t|A=2)', 'U(t|A=3)')
grid on
